package org.github.manx98.jlibhac.tools.ncm;

import lombok.Data;
import org.github.manx98.jlibhac.common.math.Uint64;
import org.github.manx98.jlibhac.fs.IStorage;
import org.github.manx98.jlibhac.tools.fssystem.ncautils.TitleVersion;

import java.io.IOException;

/**
 * @author Manx98
 * @version 1.0
 * @since 2022/10/6 18:41
 */
@Data
public class CnmtPrevMetaEntry {
    public Uint64 TitleId;
    public TitleVersion Version;
    public ContentMetaType Type;
    public byte[] Hash;
    public short ContentCount;
    public short CnmtPrevMetaEntryField32;
    public int CnmtPrevMetaEntryField34;

    public CnmtPrevMetaEntry(IStorage reader) throws IOException {
        TitleId = reader.readUint64();
        Version = new TitleVersion(reader.readUint32(), false);
        Type = ContentMetaType.valueOf(reader.readByte());
        reader.setPosition(reader.getPosition() + 3);
        Hash = reader.readBytes(0x20);
        ContentCount = reader.readShort();
        CnmtPrevMetaEntryField32 = reader.readShort();
        CnmtPrevMetaEntryField34 = reader.readInt();
    }
}
